flutter replace character in string

145

newString = 'resume';
newString.replaceAll('e', 'é'); // it returns the string   'résumé'

// And you can use a regex to search like a needle in a haystack:
'resume'.replaceAll(RegExp(r'e'), ‘é’); // 'résumé'
void main(){
     
    String str = 'Hello TutorialKart. Hello User.';
     
    //replace subString
    String result = str.replaceAll('Hello', 'Hi');
     
    print(result);
}
Output:
Hi TutorialKart. Hi User.
---------------------------------
void main(){
     
    String str = 'Hello TutorialKart. Hello User.';
     
    //replaceAll() chaining
    String result = str.replaceAll('Hello', 'Hi').replaceAll('User', 'Client');
     
    print(result);
}

Output:
Hi TutorialKart. Hi Client.

Comments

Submit
0 Comments